from sklearn.cluster import AffinityPropagation
from sklearn import metrics
import numpy as np

import optionExcel

# X = np.array([[1, 2, 3, 4], [1, 4, 3, 3], [1, 0, 4, 5],
#               [4, 2, 5, 6], [4, 6, 3, 2], [4, 0, 3, 5], [4, 1, 2, 5], [4, 3, 3, 2]])
#
# clustering = AffinityPropagation().fit(X)
#
# cluster_centers_indices = clustering.cluster_centers_indices_
# n_clusters_ = len(cluster_centers_indices)


# print(clustering.labels_)
# print("xxxxx1")
# print(n_clusters_)
# print("xxxxx4")
# print(clustering.cluster_centers_indices_)
# print("xxxxx2")
# print(clustering.predict([[0, 0, 1, 5], [4, 1, 4, 3]]))
# print("xxxxx3")
# print(clustering.cluster_centers_)


# print('Estimated number of clusters: %d' % n_clusters_)
# print("Homogeneity: %0.3f" % metrics.homogeneity_score(labels_true, labels))
# print("Completeness: %0.3f" % metrics.completeness_score(labels_true, labels))
# print("V-measure: %0.3f" % metrics.v_measure_score(labels_true, labels))
# print("Adjusted Rand Index: %0.3f"
#       % metrics.adjusted_rand_score(labels_true, labels))
# print("Adjusted Mutual Information: %0.3f"
#       % metrics.adjusted_mutual_info_score(labels_true, labels))
# print("Silhouette Coefficient: %0.3f"
#       % metrics.silhouette_score(X, labels, metric='sqeuclidean')

if __name__ == '__main__':
    data = optionExcel.read_excel()
    #print(X)
    mydata = np.array(data).T
   # X = testmatlab.GowerSim(mydata, mydata, rangeVec)

    ap = AffinityPropagation().fit(mydata)
    apindices = ap.cluster_centers_indices_
    n_apindeices = len(apindices)
    labels = ap.labels_


    print("labels", ap.labels_)
    print("affinity", ap.affinity)
    print("indec", apindices)
    print("clustercenters", ap.cluster_centers_)
